package org.misalen.web.database.repository.mysql;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.misalen.web.database.dao.mysql.impl.BaseMySqlDaoImpl;
import org.misalen.web.database.model.mysql.sys.SysWordbook;
import org.springframework.stereotype.Repository;

@Repository
public class SysWordbookRepository extends BaseMySqlDaoImpl<SysWordbook> {
	
	public SysWordbook getByCode(String wbCode) {
		Session session = this.openSession();
		Criteria criteria = session.createCriteria(SysWordbook.class, "a");
		criteria.setCacheable(true);
		criteria.add(Restrictions.eq("wordbookCode", wbCode));
		SysWordbook sysWordbook = (SysWordbook) criteria.list().get(0);
		closeSession(session);
		return sysWordbook;
	}

}